package school.Test;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MyFrame1_1 extends JFrame {
    JTextField tf1,tf2;
    JButton b1;
    MyFrame1_1(String s){
        super(s);
        setSize(600,600);
        tf1=new JTextField(20);
        tf2=new JTextField(20);
        b1=new JButton("复制");
        add(tf1);
        add(tf2);
        add(b1);

        setLayout(new FlowLayout());
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        H h=new H();
        b1.addActionListener(h);
    }
    class H implements ActionListener{
        public void actionPerformed(ActionEvent e){
            String s=tf1.getText();
            tf2.setText(s);
            tf1.setText("  ");
        }
    }
    public static void main(String[] args) {
        new MyFrame1_1("第一个窗口");
    }
}
